# -*- encoding: utf-8 -*-
# author:lmolhw
# datetime:2020-5-6 14:32

"""
文件说明：
    对合成的图片和labels进行处理，拼接
"""
import os
def open_txt(file_name):
    with open(file_name, 'r+') as f:
        try:
            line = f.readline()
            while line:
                yield line.strip()
                line = f.readline()

        except:
            print('No value')

path1 = '/data1/lhw/workspace/TextRecognitionDataGenerator/trdg/output/ID/test'
labels1 = os.path.join(path1, 'labels.txt')
out_labels1 = open(os.path.join(path1, 'jointed_labels.txt'), 'w')
for line in open_txt(labels1):
    file, label = line.split('\t')
    new_path = os.path.join(path1, file.strip())
    out_labels1.writelines(new_path + '\t' + label.strip() + '\n')
